import tkinter as tk
from tkinter import messagebox
def click():
    
    lst_txt=txt.get().replace(".","").split(' ')
    y=txt2.get()
    n=False
    lst.delete(0,lst.size()-1)
    for i in lst_txt:
        if y in i:
            lst.insert(tk.END,i)
            n=True
    if not n:
        messagebox.showinfo("Message box","Can't find the letter in your text")

win=tk.Tk()
win.title('单词查找')
lbl=tk.Label(win,text='输入一段文本')
lbl2=tk.Label(win,text='输入你要查询的单词')
txt=tk.Entry(win)
txt2=tk.Entry(win)
txt3=tk.Entry(win)
lbl3=tk.Label(win,text='显示结果')
lst=tk.Listbox(win,height=5)
btn=tk.Button(win,text='获取单词',command=click)
lbl.grid(row=0,column=0,padx=10,pady=10)
txt.grid(row=1,column=0,padx=10,pady=10)
lbl2.grid(row=2,column=0)
txt2.grid(row=3,column=0)
lbl3.grid(row=2,column=1)
btn.grid(row=4,column=0)
lst.grid(row=3,column=1)

win.mainloop()